package com.wzh.borrow.controller;

import java.util.Arrays;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.wzh.borrow.entity.RefundEntity;
import com.wzh.borrow.service.RefundService;
import com.wzh.common.utils.PageUtils;
import com.wzh.common.utils.R;



/**
 * 
 *
 * @author wzh
 * @email 1281204121@qq.com
 * @date 2022-01-27 21:23:52
 */
@RestController
@RequestMapping("borrow/refund")
public class RefundController {
    @Autowired
    private RefundService refundService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = refundService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{rid}")
    public R info(@PathVariable("rid") Integer rid){
		RefundEntity refund = refundService.getById(rid);

        return R.ok().put("refund", refund);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody RefundEntity refund){
		refundService.add(refund);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody RefundEntity refund){
		refundService.updateById(refund);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] rids){
		refundService.removeByIds(Arrays.asList(rids));

        return R.ok();
    }

}
